<?php

namespace app\store\validate;

use think\Validate;

class GroupGoodsValidate extends Validate
{
    protected $rule = [
        'sort' => 'require|integer|egt:0',
        'goods_name' => 'require|max:255',
        'main_image' => 'require',
        'goods_images' => 'require|array',
        'group_num' => 'requireIf:type,1|integer',
        'content' => 'require',
        'goods_attr' => 'require',
        'skus' => 'require',
        'status' => 'require|in:0,1',
    ];


    protected $message = [
        'id.require' => '非法请求',
        'id.integer' => '非法请求',
        'sort.require' => '排序不能为空',
        'group_num.requireIf' => '请输入拼团人数',
        'group_num.integer' => '不合法的拼团人数值',
        'goods_name.require' => '请输入商品名称!',
        'main_image.require' => '请上传商品主图',
        'goods_images.require' => '请上传商品轮播图',
        'content.require' => '请输入商品详情!',
        'goods_attr.require' => '请设置商品属性',
        'skus.require' => '商品规格不能为空',
        'status.in' => '无效的状态值!',
    ];


    public function sceneSwitch()
    {
        return $this->only(['id','status'])
                    ->append('id', 'require|integer');
    }

    public function sceneEdit()
    {
    	return $this->only(['id','sort','group_num','goods_name','main_image','goods_images','content','skus','status'])
                    ->append('id', 'require|integer');
            
    }   
}